package org.example.flinktest;

import org.apache.flink.api.java.DataSet;
import org.apache.flink.api.java.ExecutionEnvironment;
import org.apache.flink.api.java.tuple.Tuple2;
import org.example.flinktest.operators.LineSplitter;

/**
 * @author SHB
 */
public class WcBatchDemo {

  public static void main(String[] args) throws Exception {
    //创建执行环境
    final ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment();

    DataSet<String> source = env.readTextFile("D:\\SHBData\\IDEAProjects\\fink-parent\\flink-quickstart-java\\src\\main\\resources\\Words.txt");
    DataSet<Tuple2<String,Integer>> result=source
        .flatMap(new LineSplitter())
        .groupBy(0)
        .sum(1);
    result.print();
  }

}
